import { BaseView } from '../base/BaseView';
import { UIManager } from '../../base/manger/UIManager';

const { ccclass, property } = cc._decorator;

@ccclass
export class DefaultCloseViewButton extends cc.Component {
    @property(cc.Node)
    viewNode: cc.Node = null

    getView(): BaseView {
        if (this.viewNode) {
            return this.viewNode.getComponent(BaseView as any)
        }
        return UIManager.getParentView(this.node)
    }

    onTouch() {
        const view = this.getView()
        if (view) {
            view.onTouchClose()
        }
    }


}


